import Taro,{useRouter} from '@tarojs/taro'
import { View,Text } from '@tarojs/components'
import { useState,useEffect } from 'react'
import {PostCard,} from '../../components'
import { getPositionDetailInfo } from '../../api/mode'
import  './index.scss'


export default function PositionDetail(){
const [positionDetailInfo,setPositionDetailInfo]=useState()//不能设置成空对象，就要为空
const [companyId,setCompanyId]=useState()//不能设置成空对象，就要为空
const openid=Taro.getStorageSync(`openid`)
const Router=useRouter();
const positionId=Router.params.positionId?Router.params.positionId:0//设置一下未查询到的处理



useEffect(()=>{
  getPositionDetailInfo(openid,positionId).then(res=>{
    console.log(res.data.data);
    setPositionDetailInfo(res.data.data)
    setCompanyId(res.data.data.companyId)
  })
}
,[])

const jumpToCompany=()=>{
  Taro.redirectTo({
    //暂时设置成显示不是专场招聘
    url:`/pages/companyDetail/companyDetail?companyId=${companyId}&isSpecial=${0}`
  })
}
  return (
    <View >
        {     positionDetailInfo
              ?  
              <PostCard Info={positionDetailInfo} isDetail={0} isCollected={positionDetailInfo.collected} canJump={false} />
              :null
        }  

          <View className='positionDetailRequest'>
              <View className='title'>
                任职要求
              </View>
              <View className='content'>
              <Text>
                任职要求:
              </Text>
              {positionDetailInfo
              ?  
            //  console.log(positionDetailInfo.appointmentRequest)
             positionDetailInfo.appointmentRequest.map((text,index)=>(<View className='contentItem' key={index}>{index+1}、{text}</View>)
              
            )
              :null
            }
              </View>
          </View>  
          
          <View className='positionDetailRequest'>
              <View className='title'>
                岗位职责
              </View>
              <View className='content'>
              <Text>
                岗位职责:
              </Text>
              {positionDetailInfo
              ?  
            //  console.log(positionDetailInfo.appointmentRequest)
             positionDetailInfo.duty.map((text,index)=>(<View className='contentItem' key={index}>{index+1}、{text}</View>)
              
            )
              :null
            }
              </View>


          </View>  

          <View className='getMore' onClick={jumpToCompany}>
                查看该公司更多职位
          </View>
</View>
  )
}